package com.atguigu.ssyx.common.auth;

import com.atguigu.ssyx.vo.user.UserLoginVo;

/**
 * @描述:获取登录用户信息类
 * @作者:胡树苑
 * @时间:2025/9/20 23:02
 */
//ThreadLocal工具类
public class AuthContextHolder {

    //用户id
    private static final ThreadLocal<Long> userId = new ThreadLocal<>();
    //用户仓库id
    private static final ThreadLocal<Long> wareId = new ThreadLocal<>();
    //用户信息对象
    private static final ThreadLocal<UserLoginVo> userLoginVo = new ThreadLocal<>();

    //userId的操作(get和set)方法
    public static void setUserId(Long _userId) {
        userId.set(_userId);
    }
    public static Long getUserId() {
        return userId.get();
    }
    //用户仓库id的操作(get和set)方法
    public static void setWareId(Long _wareId) {
        wareId.set(_wareId);
    }
    public static Long getWareId() {
        return wareId.get();
    }
    //用户信息对象的操作(get和set)方法
    public static void setUserLoginVo(UserLoginVo _userLoginVo) {
        userLoginVo.set(_userLoginVo);
    }
    public static UserLoginVo getUserLoginVo() {
        return userLoginVo.get();
    }
}
